package com.rceeslca.modules.cam.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.rceeslca.common.utils.Result;
import com.rceeslca.modules.cam.entity.CamCourseItem;
import com.rceeslca.modules.cam.param.PageQueryParam;
import com.rceeslca.modules.cam.service.CamTeacherService;
import com.rceeslca.modules.cam.vo.AttenCourseVo;
import com.rceeslca.modules.cam.vo.CamTeacherCourseVo;
import io.swagger.annotations.Api;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 教师
 */
@Api(tags="教师")
@AllArgsConstructor
@RestController
@RequestMapping("/cam/teacher")
public class CamTeacherController {

    @Autowired
    private CamTeacherService camTeacherService;


    /**
     * 分页查询课程
     * @param param 条件参数
     */
    @PostMapping("pageCourse")
    public Result<IPage<CamTeacherCourseVo>> pageCourse(@RequestBody PageQueryParam<CamTeacherCourseVo> param) {

        Page<CamTeacherCourseVo> page = new Page<>(param.getPageNum(),param.getPageSize());
        IPage<CamTeacherCourseVo> iPage = camTeacherService.pageCourse(page,param.getQuery());

        return new Result<IPage<CamTeacherCourseVo>>().ok(iPage);
    }


    /**
     * 开始考勤
     * @param param 参数
     */
    @PostMapping("startCheck")
    public Result startCheck(@RequestBody CamCourseItem param) {

        camTeacherService.startCheck(param);

        return new Result();
    }


    /**
     * 结束考勤
     * @param param 参数
     */
    @PostMapping("endCheck")
    public Result endCheck(@RequestBody CamCourseItem param) {

        camTeacherService.endCheck(param);

        return new Result();
    }


    /**
     * 同意请假
     * @param param 参数
     */
    @PostMapping("agreeLeave")
    public Result agreeLeave(@RequestBody AttenCourseVo param) {

        camTeacherService.agreeLeave(param);

        return new Result();
    }


    /**
     * 拒绝请假
     * @param param 参数
     */
    @PostMapping("refuseLeave")
    public Result refuseLeave(@RequestBody AttenCourseVo param) {

        camTeacherService.refuseLeave(param);

        return new Result();
    }

}
